package scenes.ponto;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Ponto {

	private double x;
	private double y;
	
	//Para o Observer
	private List<Observer> observadores = new ArrayList<Observer>();

	public Ponto(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	public double getX() {
		return x;
	}
	
	public double getY() {
		return y;
	}
	
	public double distancia(Ponto b) {
		return (double) Math.sqrt(Math.pow(b.getX() - this.getX(), 2) + Math.pow(b.getY() - this.getY(), 2)); 
	}
	
	public boolean menor(Ponto b) {
		if(this.getX() <= b.getX() && this.getY() <= b.getY()){
			return true;
		}
		return false;
	}
	
	public String toString() {
		return "(" + x + ", " + y + ")";
	}

	//Para o Observer
	public void addObserver(Observer observer) {
		observadores.add(observer);
	}
	
	//Para o Observer
	public void removeObserver(Observer observer) {
		observadores.remove(observer);
	}
	
	//Para o Observer
//	public void notificar() {
//		Iterator it = observadores.iterator();
//		
//		while(it.hasNext()) {
//			Observer observer = (Observer) it.next();
//			observer.atualizar(this);
//		}
//	}
}  
